# CMake 最低版本号要求
cmake_minimum_required (VERSION 3.20)

if(POLICY CMP0042)
    cmake_policy(SET CMP0042 NEW)  # CMake 3.0+ (2.8.12): MacOS "@rpath" in target's install name
endif()

# 项目工程名
project (ch02)

# 下面两个用法的结果是相同的,set会修改SRC_LIST的值，aux_source_directory 会增加
set(SRC_Ex2_3 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_3.cpp)
set(SRC_Ex2_8 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_8.cpp)
set(SRC_Ex2_16 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_16.cpp)
set(SRC_Ex2_17 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_17.cpp)
set(SRC_Ex2_18 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_18.cpp)
set(SRC_Ex2_26 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_const_extern.cpp ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_const_extern_share_on_many_files.cpp)
set(SRC_Ex2_34 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_34.cpp)
set(SRC_Ex2_36 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_36.cpp)
set(SRC_Ex2_41_1 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_41_1.cpp)
set(SRC_Ex2_41_2 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_41_2.cpp)
set(SRC_Ex2_41_3 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_41_3.cpp)
set(SRC_Ex2_42_1 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_42_1.cpp)
set(SRC_Ex2_42_2 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_42_2.cpp)
set(SRC_Ex2_42_3 ${CMAKE_CURRENT_SOURCE_DIR}/exercise2_42_3.cpp)

#aux_source_directory(. SRC_LIST)


# 指定可执行文件存放目录
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)


# 构建可执行程序
ADD_EXECUTABLE(exercise2_3 ${SRC_Ex2_3})
ADD_EXECUTABLE(exercise2_8 ${SRC_Ex2_8})
ADD_EXECUTABLE(exercise2_16 ${SRC_Ex2_16})
ADD_EXECUTABLE(exercise2_17 ${SRC_Ex2_17})
ADD_EXECUTABLE(exercise2_18 ${SRC_Ex2_18})
ADD_EXECUTABLE(exercise2_26 ${SRC_Ex2_26})
ADD_EXECUTABLE(exercise2_34 ${SRC_Ex2_34})
ADD_EXECUTABLE(exercise2_36 ${SRC_Ex2_36})
ADD_EXECUTABLE(exercise2_41_1 ${SRC_Ex2_41_1})
ADD_EXECUTABLE(exercise2_41_2 ${SRC_Ex2_41_2})
ADD_EXECUTABLE(exercise2_41_3 ${SRC_Ex2_41_3})
ADD_EXECUTABLE(exercise2_42_1 ${SRC_Ex2_42_1})
ADD_EXECUTABLE(exercise2_42_2 ${SRC_Ex2_42_2})
ADD_EXECUTABLE(exercise2_42_3 ${SRC_Ex2_42_3})
#如何编译和使用
# mkdir -p D4Books/T1PrimerCpp/ch02/build
# cd D4Books/T1PrimerCpp/ch02/build
# cmake ..
# make or cmake --build .

#exercise2_3
# bin/exercise2_3

#the same as above ...